class Page16 extends BaseScreen {
    public constructor() {
        super();
        this.skinName = "resource/eui_skins/Page16Skin.exml";
    }

	private img_1: eui.Image;
    private img_2: eui.Image;
    private img_3: eui.Image;
    private img_4: eui.Image;
	private img_5: eui.Image;
	private img_6: eui.Image;
    private img_7:eui.Image;
    private img_0:eui.Image;
    private down_group:eui.Group;
    private cutImg;
    protected childrenCreated(): void {
        super.childrenCreated();
        this.anchorOff(this.img_4);
        this.anchorOff(this.img_5);
        
        this.init_view();
        this.resetui();
        this.showImgToHtml('');
    }

    public resetui(){
        this.img_1.alpha = 0;
		this.img_2.alpha = 0;
		this.img_3.scaleY = 0;
        this.img_4.visible = this.img_5.visible = true;
		this.img_4.scaleY = this.img_4.scaleY = 0;
		this.img_5.scaleX = this.img_5.scaleY = 0;
		this.img_6.alpha = 0.3;
        this.visible = false;
        var gameDiv = document.getElementById("btn_div");
		gameDiv.style.display = "none";
    }

    public init_view() {
    }

    public showPage() {
        // super.showPage();
        egret.Tween.removeTweens(this);
        egret.Tween.removeTweens(this.img_1);
        egret.Tween.removeTweens(this.img_2);
        egret.Tween.removeTweens(this.img_3);
        egret.Tween.removeTweens(this.img_4);
        egret.Tween.removeTweens(this.img_5);
        egret.Tween.removeTweens(this.img_6);
        egret.Tween.removeTweens(this.img_7);

        if (this.is_start_mv) {
            return;
        }
        this.is_start_mv = true;

        this.resetui();
        this.visible = true;
        let self = this;
        egret.Tween.get(this.img_1).wait(200).to({alpha:1}, 1000);
        egret.Tween.get(this.img_2).wait(200).to({alpha:1}, 1000);
		egret.Tween.get(this.img_3).wait(300).to({scaleY:1}, 1000, egret.Ease.backOut);
        egret.Tween.get(this.img_4).wait(1000).to({scaleY:1,scaleX:1}, 1000, egret.Ease.backOut);
        egret.Tween.get(this.img_5).wait(1500).to({scaleX:1,scaleY:1}, 1000, egret.Ease.backOut).call(function(){
            // self.img_4.visible = self.img_5.visible = false;
            var gameDiv = document.getElementById("btn_div");
		    gameDiv.style.display = "block";
        });
		egret.Tween.get(this.img_6,{loop:true}).to({alpha:1}, 2500).to({alpha:0.3}, 2500);
        egret.Tween.get(this.img_7).wait(2000).to({scaleY:1}, 1000, egret.Ease.backOut);
        
    }

    public out_page(){
        this.is_start_mv = false;
        var gameDiv = document.getElementById("btn_div");
		gameDiv.style.display = "none";
    }

    public resize(): void {
         super.resize();
         this.down_group.y = this.height - this.down_group.height;
    }

    public showImgToHtml(htmlCodeUrl: string) {
        // var scales:number = document.body.clientHeight/this.height;
		// var gameDiv = document.getElementById("btn_div");
		// gameDiv.style.display = "none";
		// this.cutImg = document.createElement("img");
		// this.cutImg.src = 'http://www.jichuancy.com/df/df_nianbao_xia/page16_10.png';
		// this.cutImg.style.position = 'absolute';
		// this.cutImg.style.top = this.img_0.y * scales + 'px';
		// this.cutImg.style.left = '0px';
		// this.cutImg.style.width = (document.body.clientWidth) + 'px';
        // this.cutImg.style.height = this.img_0.height * scales + 'px';
        // this.cutImg.style.opacity = '0';
		// gameDiv.appendChild(this.cutImg);

        var scales:number = document.body.clientHeight/this.height;
        var scalesx:number = document.body.clientWidth/this.width;
		var gameDiv = document.getElementById("btn_div");
		gameDiv.style.display = "none";
		this.cutImg = document.createElement("img");
		this.cutImg.src = 'http://www.jichuancy.com/df/df_nianbao_xia/page16_06_07.png';
		this.cutImg.style.position = 'absolute';
		this.cutImg.style.top = (this.img_4.y - this.img_4.height * 0.5) * scales + 'px';
        this.cutImg.style.left = (this.img_4.x - this.img_4.width * 0.5) * scales + 'px';
		this.cutImg.style.width = (this.img_4.width*scales) + 'px';
        this.cutImg.style.height = this.img_4.height * scales + 'px';
        // this.cutImg.style.opacity = '0';
		gameDiv.appendChild(this.cutImg);

		var cutImg2 = document.createElement("img");
		cutImg2.src = 'http://www.jichuancy.com/df/df_nianbao_xia/page16_06_09.png';
		cutImg2.style.position = 'absolute';
		cutImg2.style.top = (this.img_5.y - this.img_5.height * 0.5)  * scales + 'px';
		cutImg2.style.left = (this.img_5.x - this.img_5.width * 0.5) * scales + 'px';
		cutImg2.style.width = (this.img_5.width*scales) + 'px';
        cutImg2.style.height = this.img_5.height * scales + 'px';
        // cutImg2.style.opacity = '0';
		gameDiv.appendChild(cutImg2);

	}

	protected process(){
        
    }
}